<?php
/**
 * @Name: Mobile.php
 * @Author: yashuai
 * @Desc
 * @Time 2021/11/2 17:34
 */

namespace App\Http\Rules;

use HugCode\PhpUnits\Utils\UtilValidator;
use Illuminate\Contracts\Validation\Rule;

class Mobile implements Rule
{
    /**
     * 判断验证是否通过
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
        if(empty(trim($value))){
            return true;
        }
        return UtilValidator::isMobile($value);
    }

    /**
     * 获取验证错误信息
     *
     * @return string
     */
    public function message()
    {
        return '请输入正确的手机号';
    }

}
